<?php

/**
 * ZView
 *
 * Zend Frameworks View Component for TYPO3
 *
 * @package    ZView
 * @copyright  Copyright (c) Zephir AG, www.zephir.ch
 */

/** Abstract class for extension */
require_once('Zend/View/Abstract.php');

/**
 * The TYPO3 view class basend on Zends abstract view class
 *
 * @package ZView
 * @copyright  Copyright (c) Zephir AG, www.zephir.ch
 */
class tx_zview extends Zend_View_Abstract {

    /**
     * The TYPO3 frontend plugin
     *
     * @var tslib_pibase
     */
    private $_pi;

    /**
     * Constructor.
     *
     * @param array $config Configuration key-value pairs.
     */
    public function __construct($config = array())
    {
    	parent::__construct($config);
    	$dir = dirname(__FILE__);
		$this->addHelperPath($dir.'/helper/incubator', 'Tx_Zview_Helper_');
		$this->addHelperPath($dir.'/helper', 'Tx_Zview_Helper_');
    }

	/**
	 * Set the TYPO3 plugin
	 *
	 * @param tslib_pibase
     * @return tx_zview_abstract
	 */
    public function setPi(tslib_pibase $pi)
    {
    	$this->_pi = $pi;
        return $this;
    }

	/**
	 * Get the TYPO3 plugin
	 *
	 * @return tslib_pibase
	 */
    public function getPi()
    {
    	return $this->_pi;
    }

    /**
     * Includes the view script in a scope with only public $this variables.
     *
     * @param string The view script to execute.
     */
    protected function _run()
    {
        include func_get_arg(0);
    }

}

if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/zview/class.tx_zview.php'])	{
	include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/zview/class.tx_zview.php']);
}
